package com.lineage.config;

import com.lineage.commons.system.LanSecurityManager;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

public final class ConfigIpCheck {
  public static int ipcount;
  
  public static int timeOutSocket;
  
  public static boolean IPCHECKPACK;
  
  public static boolean IPCHECK;
  
  public static int TIMEMILLIS;
  
  public static int COUNT;
  
  public static boolean SETDB;
  
  public static boolean UFW;
  
  public static boolean ISONEIP;
  
  public static int ONETIMEMILLIS;
  
  private static final String _ipcheck = "./config/ipcheck.properties";
  
  public static void load() throws ConfigErrorException {
    Properties set = new Properties();
    try {
      InputStream is = new FileInputStream(new File("./config/ipcheck.properties"));
      set.load(is);
      is.close();
      IPCHECKPACK = Boolean.parseBoolean(set.getProperty("IPCHECKPACK", "false"));
      if (IPCHECKPACK) {
        LanSecurityManager manager = new LanSecurityManager();
        manager.stsrt_cmd_tmp();
      } 
      IPCHECK = Boolean.parseBoolean(set.getProperty("IPCHECK", "false"));
      TIMEMILLIS = Integer.parseInt(set.getProperty("TIMEMILLIS", "1000"));
      ipcount = Integer.parseInt(set.getProperty("ipcount", "3"));
      COUNT = Integer.parseInt(set.getProperty("COUNT", "10"));
      SETDB = Boolean.parseBoolean(set.getProperty("SETDB", "false"));
      UFW = Boolean.parseBoolean(set.getProperty("UFW", "true"));
      ISONEIP = Boolean.parseBoolean(set.getProperty("ISONEIP", "false"));
      ONETIMEMILLIS = Integer.parseInt(set.getProperty("ONETIMEMILLIS", "20000"));
      timeOutSocket = Integer.parseInt(set.getProperty("timeOutSocket", "60"));
      if (ONETIMEMILLIS != 0) {
        LanSecurityManager manager = new LanSecurityManager();
        manager.stsrt_cmd();
      } 
    } catch (Exception e) {
      throw new ConfigErrorException("设置档案遗失: ./config/ipcheck.properties");
    } finally {
      set.clear();
    } 
  }
}
